using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using EzDesk.Attendance.AttendanceImpl;
using EzDesk.Attendance.MobileWeb.Controllers;
using EzDesk.EzAppApi.Web.Utility.Controllers;

namespace EzDesk.Attendance.MobileWeb.Controllers
{
    public enum AttendanceRole
    {
        Employee,
        Manager,
    }

    public class AttendanceBaseController : EzAppController
    {
        protected AttendanceService _attendanceService;

        public ActionResult ReturnPage(string r, string txtInfo)
        {
            if (String.IsNullOrEmpty(r))
            {
                return ReturnView("Index", "Attendance", null, null);
            }
            else
            {
                return null;
            }
        }

        public IList<AttendanceRole> CurrentRoles
        {
            get
            {
                var roles = new List<AttendanceRole>();

                Guid userId = CurrentUserId;
                var cfg = _attendanceService.GetAttendanceConfig();

                if (cfg.AttendanceManagerUserIds.Contains(userId.ToString()))
                {
                    roles.Add(AttendanceRole.Manager);
                }

                if (cfg.AttendanceUserIds.Contains(userId.ToString()))
                {
                    roles.Add(AttendanceRole.Employee);
                }
                return roles;
            }
        }
    }
}
